package WinterHomework.day07;

import java.util.LinkedList;
import java.util.Queue;

//将一个字符串从左开始前K个字符进行旋转，左旋数组，例如："abcdef",k=2,则结果为："cdefab"
public class Demo02 {
    public static void main(String[] args) {
        LeftRotateString("123456",4);
    }

    public static void LeftRotateString(String str, int k) {
        Queue<Character> queue = new LinkedList<>();
        for (int i = 0; i < str.length(); i++) {
            queue.offer(str.charAt(i));
        }
        for (int i = 0; i < k; i++) {
            queue.offer(queue.poll());
        }
        String sb = "";
        for (int i = 0; i < str.length(); i++) {
            sb=sb+queue.poll();
        }
        System.out.println(sb);
    }
}
